package com.gist.cithub.service.service.impl;

import com.gist.cithub.service.entity.AverageScoreEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gist.common.utils.PageUtils;
import com.gist.common.utils.Query;

import com.gist.cithub.service.dao.HistorylistDao;
import com.gist.cithub.service.entity.HistorylistEntity;
import com.gist.cithub.service.service.HistorylistService;


@Service("historylistService")
public class HistorylistServiceImpl extends ServiceImpl<HistorylistDao, HistorylistEntity> implements HistorylistService {
    @Autowired
    HistorylistDao historylistDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<HistorylistEntity> page = this.page(
                new Query<HistorylistEntity>().getPage(params),
                new QueryWrapper<HistorylistEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<HistorylistEntity> getHistoryByServiceId(Integer serviceId) {
        QueryWrapper<HistorylistEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.and(
                wrapper ->
                        wrapper.eq("service_id", serviceId)
        );
        List<HistorylistEntity> res= historylistDao.selectList(queryWrapper);
        return res;
    }

}